import getApiData, { getCPASTableAipsData, getDesignTableAipsData } from "@/services/cpasRequest";
import { getAllVerifyData } from "@/services/verifyAll";

export async function getWscwbbData(params: {
  dbname: string;
  type: string;
  cols: string;
  keys: string;
  filterConditions: string
}) {
  try {
    const res = await getApiData("account.ws.wscwbb", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: '接口account.ws.wscwbb出错了！',
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口account.ws.wscwbb出错了！',
      success: false,
    });
  }

}
// 获取账套
export async function getAccountInfo(params: {
  dbname: string;
}) {
  try {
    const res = await getApiData("account.accountInfo.getDataList", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口account.ws.getDataList出错了！',
      success: false,
    });
  }
}
/**
 * 获取基础报表数据列映射
 */
export const getColumnsMapByReport = async (params: any) => {
  try {
    const res = await getCPASTableAipsData('getColumnsMapByReport', params)
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口getColumnsMapByReport出错了！',
      success: false,
    });
  }
};

/**
 * 获取报表基础数据行映射
 * @param tid
 */
export const getRowsMapByReport = async (params: any) => {

  try {
    const res = await getCPASTableAipsData('getRowsMapByReport', params)
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口getRowsMapByReport出错了！',
      success: false,
    });
  }

};

/**
 * 获取表数据根据name
 */

export const getDesignTableInfoByNameApi = async (params: any) => {

  const res = await getCPASTableAipsData('getCpasTableDataByName', params)
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.reject({
    data: res.data,
    success: false,
  });
};

/**
 * 获取财务报表表名
 * @param tid
 */
export const getAllCpasTable = async (params: any) => {

  try {
    const res = await getDesignTableAipsData('getAllCpasTable', params)
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口getAllCpasTable出错了！',
      success: false,
    });
  }
};
